import java.util.ArrayList;
import java.util.List;

import nlp.dao.MessageDao;
import nlp.model.Message;
import weibo4j.Paging;
import weibo4j.Status;
import weibo4j.Trends;
import weibo4j.User;
import weibo4j.Weibo;
import weibo4j.WeiboException;

public class Test {

	/**
	 * @param args
	 * @author Chenjie
	 */
	public static void main(String args[]) {

		System.setProperty("weibo4j.oauth.consumerKey", Weibo.CONSUMER_KEY);
		System.setProperty("weibo4j.oauth.consumerSecret",
				Weibo.CONSUMER_SECRET);
		Weibo weibo = new Weibo();

		/*
		 * 此处需要填写AccessToken的key和Secret，可以从OAuthUpdate的执行结果中拷贝过来
		 */
		weibo.setToken("fa215104e29bada2f7fcae2a9200e888",
				"1b082671818aba6c02c8019de1f46f3d");

		User user = null;
		List<Status> statusList=new ArrayList<Status>();
		List<Trends> trendsList=new ArrayList<Trends>();
		try {
//			user = weibo.verifyCredentials();
//			user=weibo.showUser("1758194777");
//			System.out.println(user);

//			trendsList=weibo.getTrendsWeekly(1);
//			for(Trends trend:trendsList){
//				Trend[] tArray=trend.getTrends();
//				System.out.println(tArray.length);
//			}
			
//			int totalCount=user.getStatusesCount();
//			System.out.println("totalCount:"+totalCount);
//			int totalPage=(totalCount%20==0)?(totalCount/20):((totalCount/20)+1);
//			System.out.println("totalPage:"+totalPage);
//			Paging page=null;
//			for(int i =1;i<=1;i++){
//				page = new Paging(i);
//				statusList=weibo.getUserTimeline(page);
//				Message msg=null;
//				MessageDao md=new MessageDao();
//				for(Status status:statusList){
//					boolean flag=status.getRetweeted_status()==null ? true:false;
////				System.out.println(flag);
//					System.out.println(status.getCreatedAt().getTime()+" || "+status.getText()+(flag ? "" :(" [RT] "+status.getRetweeted_status().getText())));
//					System.out.println("-----------------------------------------------------------------------------------------------------------");
//					
//					msg=new Message();
//					msg.setId(status.getId());
//					msg.setText(status.getText());
//					msg.setCreateAt(status.getCreatedAt().getTime()+"");
//					if(!flag){
//						Status rtStatus=status.getRetweeted_status();
//						msg.setRtId(rtStatus.getId());
//						msg.setRtText(rtStatus.getText());
//						msg.setRtCreateAt(rtStatus.getCreatedAt()==null?"":rtStatus.getCreatedAt().getTime()+"");
//					}
//					md.insert(msg);
//				}
//			}
			

			List<Status> moshengren=new ArrayList<Status>();
			moshengren=weibo.getUserTimeline("Sonyfe25cp",new Paging(1,550));
			for(Status s:moshengren){
				System.out.println(s.getText());
			}
			
			List<User> follower = weibo.getFollowersStatuses();
			for(User user_fo : follower){
				System.out.println(user_fo.getName());
			}
			List<User> friends = weibo.getFriendsStatuses();
			for(User user_fr : friends){
				System.out.println(user_fr.getName());
			}
			
		} catch (WeiboException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}

	}

}
